home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / standard / mp.z / mp
Encoding:
Text File  |  2002-10-03  |  13.0 KB  |  255 lines

  1. MP(3C)                                                 Last changed: 4-9-99
  2.  
  3.  
  4. NNAAMMEE
  5.      mmpp, mmpp__bblloocckk, mmpp__bblloocckkttiimmee, mmpp__ccrreeaattee, mmpp__ddeessttrrooyy, mmpp__mmyy__tthhrreeaaddnnuumm,
  6.      mmpp__nnuummtthhrreeaaddss, mmpp__sseett__nnuummtthhrreeaaddss, mmpp__sseettuupp, mmpp__uunnbblloocckk, mmpp__sseettlloocckk,
  7.      mmpp__ssuuggggeesstteedd__nnuummtthhrreeaaddss, mmpp__uunnsseettlloocckk, mmpp__bbaarrrriieerr,
  8.      mmpp__iinn__ddooaaccrroossss__lloooopp, mmpp__sseett__ssllaavvee__ssttaacckkssiizzee - C multiprocessing
  9.      utility functions
  10.  
  11. SSYYNNOOPPSSIISS
  12.      vvooiidd mmpp__bblloocckk(())
  13.  
  14.      vvooiidd mmpp__uunnbblloocckk(())
  15.  
  16.      vvooiidd mmpp__bblloocckkttiimmee((_i_t_e_r_s))
  17.      iinntt _i_t_e_r_s
  18.  
  19.      vvooiidd mmpp__sseettuupp(())
  20.  
  21.      vvooiidd mmpp__ccrreeaattee((_n_u_m))
  22.      iinntt _n_u_m
  23.  
  24.      vvooiidd mmpp__ddeessttrrooyy(())
  25.  
  26.      iinntt mmpp__nnuummtthhrreeaaddss(())
  27.  
  28.      vvooiidd mmpp__sseett__nnuummtthhrreeaaddss((_n_u_m))
  29.      iinntt _n_u_m
  30.  
  31.      iinntt mmpp__mmyy__tthhrreeaaddnnuumm(())
  32.  
  33.      iinntt mmpp__iiss__mmaasstteerr(())
  34.  
  35.      vvooiidd mmpp__sseettlloocckk(())
  36.  
  37.      vvooiidd mmpp__uunnsseettlloocckk(())
  38.  
  39.      vvooiidd mmpp__bbaarrrriieerr(())
  40.  
  41.      iinntt mmpp__iinn__ddooaaccrroossss__lloooopp(())
  42.  
  43.      vvooiidd mmpp__sseett__ssllaavvee__ssttaacckkssiizzee((_s_i_z_e))
  44.      iinntt _s_i_z_e
  45.  
  46.      uunnssiiggnneedd iinntt mmpp__ssuuggggeesstteedd__nnuummtthhrreeaaddss((_n_u_m))
  47.      uunnssiiggnneedd iinntt _n_u_m
  48.  
  49. IIMMPPLLEEMMEENNTTAATTIIOONN
  50.      IRIX systems
  51.  
  52. DDEESSCCRRIIPPTTIIOONN
  53.      The following routines control the parallelism used in C programs.
  54.      Although not needed by most users, they help to tune specific
  55.      applications.
  56.  
  57.      mmpp__bblloocckk
  58.           Puts all slave threads to sleep via bblloocckkpprroocc(2).  This frees the
  59.           processors for use by other jobs.  This is useful if it is known
  60.           that the slaves will not be needed for some time, and the machine
  61.           is being shared by several users.  Calls to mmpp__bblloocckk may not be
  62.           nested; a warning is issued if an attempt to do so is made.
  63.  
  64.      mmpp__uunnbblloocckk
  65.           Wakes up the slave threads that were previously blocked via
  66.           mmpp__bblloocckk.  It is an error to unblock threads that are not
  67.           currently blocked; a warning is issued if an attempt is made to
  68.           do so.
  69.  
  70.           It is not necessary to explicitly call mmpp__uunnbblloocckk.  When a
  71.           parallel region is entered, a check is made, and if the slaves
  72.           are currently blocked, a call is made to mmpp__uunnbblloocckk
  73.           automatically.
  74.  
  75.      mmpp__bblloocckkttiimmee
  76.           Controls the amount of time a slave thread waits for work before
  77.           giving up.  When enough time has elapsed, the slave thread blocks
  78.           itself.  This automatic blocking is independent of the user level
  79.           blocking provided by the mmpp__bblloocckk/mmpp__uunnbblloocckk calls.  Slave
  80.           threads that have blocked themselves will be automatically
  81.           unblocked upon entering a parallel region.  The argument to
  82.           mmpp__bblloocckkttiimmee is the number of times to spin in the wait loop.  By
  83.           default, it is set to 10,000,000.  This takes about .25 seconds
  84.           on a 200MHz processor.  As a special case, an argument of 0
  85.           disables the automatic blocking, and the slaves will spin wait
  86.           without limit.  The environment variable MMPP__BBLLOOCCKKTTIIMMEE may be set
  87.           to an integer value.  It acts like an implicit call to
  88.           mmpp__bblloocckkttiimmee during program startup.
  89.  
  90.      mmpp__ddeessttrrooyy
  91.           Deletes the slave threads.  They are stopped by forcing them to
  92.           call eexxiitt(2).  An alternative is to specify mmpp__bblloocckk.
  93.  
  94.      mmpp__ccrreeaattee
  95.           Creates and initializes threads.  It creates enough threads so
  96.           that the total number is equal to the argument.  Because the
  97.           calling thread counts as one, mmpp__ccrreeaattee will create one less than
  98.           its argument in new slave threads.
  99.  
  100.      mmpp__sseettuupp
  101.           Also creates and initializes threads.  It takes no arguments.  It
  102.           simply calls mmpp__ccrreeaattee using the current default number of
  103.           threads.  Usually, the default number is equal to the number of
  104.           CPUs currently on the machine.  If the user has not already
  105.           called either of the thread creation routines, then mmpp__sseettuupp is
  106.           invoked automatically when the first parallel region is entered.
  107.           If the MMPP__SSEETTUUPP environment variable is set, then mmpp__sseettuupp is
  108.           called during initialization, before any user code is executed.
  109.  
  110.      mmpp__nnuummtthhrreeaaddss
  111.           Returns the number of threads that would participate in an
  112.           immediately following parallel region.  If the threads have
  113.           already been created, then it returns the current number of
  114.           threads.  If the threads have not been created, then it returns
  115.           the current default number of threads.  The count includes the
  116.           master thread.  Knowing this count can be useful in optimizing
  117.           certain kinds of parallel loops by hand, but this function has
  118.           the side-effect of freezing the number of threads to the returned
  119.           value.  As a result, this routine should be used sparingly.  To
  120.           determine the number of threads without this side-effect, see the
  121.           following description of mmpp__ssuuggggeesstteedd__nnuummtthhrreeaaddss.
  122.  
  123.      mmpp__sseett__nnuummtthhrreeaaddss
  124.           Sets the current default number of threads to the specified
  125.           value.  Note that this call does not directly create the threads,
  126.           it only specifies the number that a subsequent mmpp__sseettuupp call
  127.           should use.  If the MMPP__SSEETT__NNUUMMTTHHRREEAADDSS environment variable is
  128.           set, it acts like an implicit call to mmpp__sseett__nnuummtthhrreeaaddss during
  129.           program startup.  For convenience when operating among several
  130.           machines with different numbers of CPUs, MMPP__SSEETT__NNUUMMTTHHRREEAADDSS can be
  131.           set to an expression involving integer literals, the binary
  132.           operators + and -, the binary functions min and max, and the
  133.           special AALLLL symbolic value, which stands for "the total number of
  134.           available CPUs on the current machine."  Thus, the following
  135.           example would set the number of threads to seven:
  136.  
  137.           setenv MP_SET_NUMTHREADS 7
  138.  
  139.      The following example sets the number of threads on a 4 CPU machine to
  140.      be one less than the number of CPUs on the current machine (but always
  141.      at least one):
  142.  
  143.           setenv MP_SET_NUMTHREADS "max(1,all-1)"
  144.  
  145.      If your configuration includes some machines with large numbers of
  146.      CPUs, it is helpful to set an upper bound. The following example will
  147.      request (no more than) 4 CPUs:
  148.  
  149.           setenv MP_SET_NUMTHREADS "min(all,4)"
  150.  
  151.      For compatibility with earlier releases, NNUUMM__TTHHRREEAADDSS is supported as a
  152.      synonym for MMPP__SSEETT__NNUUMMTTHHRREEAADDSS.
  153.  
  154.      mmpp__mmyy__tthhrreeaaddnnuumm
  155.           Returns an integer between 0 and _n-1 where _n is the value
  156.           returned by mmpp__nnuummtthhrreeaaddss.  The master process is always thread
  157.           0.  This is occasionally useful for optimizing certain kinds of
  158.           loops by hand.
  159.  
  160.      mmpp__iiss__mmaasstteerr
  161.           Returns 1 if called by the master process, otherwise 0 is
  162.           returned..
  163.  
  164.      mmpp__sseettlloocckk
  165.           Provides convenient (though limited) access to the locking
  166.           routines.  The convenience is that no set up is required; it may
  167.           be called directly without any preliminaries.  The limitation is
  168.           that there is only one lock.  It is analogous to the
  169.           uusssseettlloocckk(3P) routine, but it takes no arguments and does not
  170.           return a value.  This is useful for serializing access to shared
  171.           variables (e.g.  counters) in a parallel region.  Note that it
  172.           will frequently be necessary to declare those variables as
  173.           vvoollaattiillee to ensure that the optimizer does not assign them to a
  174.           register.
  175.  
  176.      mmpp__uunnsseettlloocckk
  177.           The companion routine for mmpp__sseettlloocckk.  It also takes no arguments
  178.           and does not return a value.
  179.  
  180.      mmpp__bbaarrrriieerr
  181.           Provides a simple interface to a single bbaarrrriieerr(3P).  It may be
  182.           used inside a parallel loop to force a barrier synchronization to
  183.           occur among the parallel threads.  The routine takes no
  184.           arguments, returns no value, and does not require any
  185.           initialization.
  186.  
  187.      mmpp__iinn__ddooaaccrroossss__lloooopp
  188.           Answers the question "Am I currently executing inside a parallel
  189.           loop?"  This is useful in certain rare situations where you have
  190.           an external routine that can be called both from inside a
  191.           parallel loop and also from outside a parallel loop, and the
  192.           routine must do different things depending on whether or not it
  193.           is being called in parallel.
  194.  
  195.      mmpp__sseett__ssllaavvee__ssttaacckkssiizzee
  196.           Sets the stacksize (in bytes) to be used by the slave processes
  197.           when they are created (via sspprrooccsspp(2)).  The default size is
  198.           16MB.  Note that slave processes only allocate their local data
  199.           onto their stack; shared data (even if allocated on the master's
  200.           stack) is not counted.
  201.  
  202.      mmpp__ssuuggggeesstteedd__nnuummtthhrreeaaddss
  203.           Uses the supplied value as a hint about how many threads to use
  204.           in subsequent parallel regions, and returns the previous value of
  205.           the number of threads to be employed in parallel regions. It does
  206.           not affect any currently executing parallel regions. The
  207.           implementation may ignore this hint depending on factors such as
  208.           overall system load.  This routine may also be called with the
  209.           value 0, in which case it simply returns the number of threads to
  210.           be employed in parallel regions without the side-effect present
  211.           in mmpp__nnuummtthhrreeaaddss..
  212.  
  213.    ##pprraaggmmaa DDiirreeccttiivveess
  214.      The MIPSpro C and C++ compilers allow you to apply the capabilities of
  215.      a Silicon Graphics multiprocessor computer to the execution of a
  216.      single job. By coding a few simple directives, the compiler splits the
  217.      job into concurrently executing pieces, thereby decreasing the wall-
  218.      clock run time of the job.
  219.  
  220.      Directives enable, disable, or modify a feature of the compiler.
  221.      Essentially, directives are command line options specified within the
  222.      input file instead of on the command line. Unlike command line
  223.      options, directives have no default setting. To invoke a directive,
  224.      you must either toggle it on or set a desired value for its level.
  225.      The following directives can be used in C (and C++) programs when
  226.      compiled with the --mmpp option (see the _M_I_P_S_p_r_o _C _a_n_d _C++ _P_r_a_g_m_a_s manual
  227.      for details on these directives):
  228.  
  229.      * ##pprraaggmmaa ppaarraalllleell
  230.  
  231.      * ##pprraaggmmaa ppffoorr
  232.  
  233.      * ##pprraaggmmaa ccrriittiiccaall
  234.  
  235.      * ##pprraaggmmaa iinnddeeppeennddeenntt
  236.  
  237.      * ##pprraaggmmaa ssyynncchhrroonniizzee
  238.  
  239.      * ##pprraaggmmaa eenntteerr ggaattee
  240.  
  241.      * ##pprraaggmmaa eexxiitt ggaattee
  242.  
  243.      * ##pprraaggmmaa ppaaggee__ppllaaccee
  244.  
  245. SSEEEE AALLSSOO
  246.      cccc(1), ff7777(1)
  247.  
  248.      mmpp(3f), ssyynncc(3c), ssyynncc(3f)
  249.  
  250.      _C _L_a_n_g_u_a_g_e _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l
  251.  
  252.      _M_I_P_S_p_r_o _F_O_R_T_R_A_N _7_7 _P_r_o_g_r_a_m_m_e_r'_s _G_u_i_d_e
  253.  
  254.      This man page is available only online.
  255.